package com.xmx.web.controller;

import com.xmx.domain.User;
import com.xmx.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Author Xumx
 * @Date 2021/3/15 11:52
 * @Version 1.0
 */
@Controller
@RequestMapping("/user")
@ResponseBody
public class UserController {

    @Autowired
    private IUserService userService;

    /*
    *   查询所有
    * */
    @RequestMapping("/findAll")
    public List<User> findAll(){
        return userService.findAll();
    }

    /*
    *   根据id查询
    * */
    @RequestMapping("/findById")
    public User findById(Integer id){
        return userService.findById(id);
    }

    /*
    *   更新
    * */
    @RequestMapping("/updateUser")
    public void updateUser(@RequestBody User user){
        userService.updateUser(user);
    }
}
